package dome3;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(filterName = "MyFilter01",urlPatterns = "/register1.do")
public class MyFilter01 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain)
            throws IOException, ServletException {
        servletResponse.setContentType("text/html;charset=UTF-8");
        servletResponse.getWriter().write("第二级过滤-MyFilter01");
        String password = servletRequest.getParameter("password");
        if(password.length()>=6 && password.length()<=30){
            filterChain.doFilter(servletRequest,servletResponse);
        }else {
            servletResponse.getWriter().write("第二级过滤-MyFilter01-拦截");
        }

    }
    @Override
    public void destroy() {
    }
}
